package com.xinyue.ext.root;

import java.util.HashMap;
import java.util.Map;

import com.xinyue.ext.data.EntityData;
import com.xinyue.ext.data.RootData;

public class ControllerRoot extends RootContext{
	//私有构造器
	private ControllerRoot() {
	}
	//私有内部类
	private static class SingletonHolder{
        private static ControllerRoot instance = new ControllerRoot();  
    }
	/***
	 * 获得实例对象
	 */
	public static ControllerRoot getInstance() {
		return SingletonHolder.instance;
	}
	
	/**
	 * 创建controller数据
	 */
	@Override
	public void freemarkerData(EntityData entity, RootData data) {
		Map<String, Object> root = new HashMap<String, Object>();
		
		root.put("package", entity.getContPackage());
		root.put("serPackage", entity.getSerPackage());
		root.put("className", entity.getClassName());

		String path = pathBuild(entity.getContPackage(), entity.getClassName(), controller_);
		
		data.setControllerPath(path);
		data.setControllerData(root);
	}
}
